// 读取数据
val studentsDF = spark.read.jdbc(databaseUrl + "students", "students", connectionProperties)

// 增加所有学生年龄1岁
val incrementedAgeDF = studentsDF.withColumn("age", $"age" + 1)

// 写回数据库，覆盖原表
incrementedAgeDF.write
  .mode(SaveMode.Overwrite)
  .jdbc(databaseUrl + "students", "students", connectionProperties)

// 验证更新结果
val verifiedDF = spark.read.jdbc(databaseUrl + "students", "students", connectionProperties)
verifiedDF.show()

// 关闭SparkSession
spark.stop()